#ifndef EMOTION_ABSTRACTEMOTIONMANAGER_H
#define EMOTION_ABSTRACTEMOTIONMANAGER_H

#include <QObject>
#include <QMap>
#include <QList>


namespace Emotion {

class AbstractEmotion;

class AbstractEmotionManager : public QObject
{
    Q_OBJECT
public:
    typedef QList<AbstractEmotion *> EmotionList;
    typedef QMap<QString, AbstractEmotion *> EmotionMap;

    enum EmotionManagerType {
        SmileyAnimationManagerType,
        TrollAnimationManagerType,
        ComicAnimationManagerType
    };

public:
    explicit AbstractEmotionManager(QObject *parent = 0);
    ~AbstractEmotionManager();

private:
    EmotionList    m_emotionList;

    EmotionMap     m_codeToEmotionMap;
    EmotionMap     m_nameToEmotionMap;
    EmotionMap     m_fullPathToEmotionMap;

    QMap<QString, QString>        m_nameToCodeMap;
    QMap<QString, QString>        m_codeToNameMap;

private:
    virtual AbstractEmotion *createEmotion(int index) const = 0;
    void append(AbstractEmotion *emotion);

protected:
    void loadEmotion();

public:
    virtual EmotionManagerType type() const = 0;

public:
    AbstractEmotion *findByCode(const QString &code) const;
    AbstractEmotion *findByName(const QString &name) const;
    AbstractEmotion *findByFullPath(const QString &fullPath) const;

    inline const EmotionList &emotionList() const {
        return m_emotionList;
    }

    inline const EmotionMap &fullPathToEmotionMap() const {
        return m_fullPathToEmotionMap;
    }

    QString getNameByCode(const QString &code) const;
    QString getCodeByName(const QString &name) const;

public:
    virtual int count() const = 0;
    int size() const;
    
};

} // namespace Emotion

#endif // EMOTION_ABSTRACTEMOTIONMANAGER_H
